﻿Imports System.Data.OleDb
Public Class hotelinformation
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


        Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("ConnectionString7").ConnectionString)
        Dim SqlString As String = "SELECT * from Comments WHERE Hotel_fxid=@f1"
        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
        cmd.CommandType = CommandType.Text
        If Request.Params("ID") = "" Then
            cmd.Parameters.AddWithValue("@f1", "1")
        Else
            cmd.Parameters.AddWithValue("@f1", Request.Params("ID"))
        End If



        oleDbConn.Open()
        Dim dataReader = cmd.ExecuteReader()
        GridView3.DataSource = dataReader
        GridView3.DataBind()

 

    End Sub

 


    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("ConnectionString7").ConnectionString)
        Dim SqlString As String = "Insert into Comments(Author,Comment,Title,Hotel_fxid) Values (@f1,@f2,@f3,@f4)"
        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
        cmd.CommandType = CommandType.Text
        cmd.Parameters.AddWithValue("@f1", fld_author.Text)
        cmd.Parameters.AddWithValue("@f2", fld_comment.Text)
        cmd.Parameters.AddWithValue("@f3", fld_title.Text)
        cmd.Parameters.AddWithValue("@f4", Request.Params("ID"))
        oleDbConn.Open()
        cmd.ExecuteNonQuery()

        Dim fillComments As String = "Select * from Comments where Hotel_fxid=@f1"
        Dim fillCommentsCmd As OleDbCommand = New OleDbCommand(fillComments, oleDbConn)
        fillCommentsCmd.CommandType = CommandType.Text
        fillCommentsCmd.Parameters.AddWithValue("@f1", Request.Params("ID"))
        Dim dataReader = cmd.ExecuteReader()
        GridView3.DataSource = dataReader
        GridView3.DataBind()

        fld_author.Text = ""
        fld_comment.Text = ""
        fld_title.Text = ""

    End Sub




End Class